<template>
  <div class="settings-page">
    <!-- 导航栏 -->
    <div class="nav-bar">
      <div class="back-button" @click="goBack">
        <span class="back-icon">←</span>
      </div>
      <div class="title">设置</div>
    </div>

    <!-- 设置列表 -->
    <div class="settings-list">
      <!-- 更换手机号 -->
      <div class="settings-item" @click="changePhone">
        <div class="item-left">
          <span class="item-icon">📱</span>
          <span class="item-text">更换手机号</span>
        </div>
        <span class="item-arrow">›</span>
      </div>

      <!-- 关于 -->
      <div class="settings-item" @click="showAbout">
        <div class="item-left">
          <span class="item-icon">ℹ️</span>
          <span class="item-text">关于</span>
        </div>
        <span class="item-arrow">›</span>
      </div>

      <!-- 退出登录 -->
      <div class="settings-item logout" @click="handleLogout">
        <div class="item-left">
          <span class="item-icon">🚪</span>
          <span class="item-text">退出登录</span>
        </div>
      </div>
    </div>

    <!-- 关于弹窗 -->
    <div v-if="showAboutModal" class="about-modal">
      <div class="modal-content">
        <div class="modal-header">
          <h3>关于珍爱</h3>
          <span class="close-btn" @click="showAboutModal = false">×</span>
        </div>
        <div class="modal-body">
          <p>珍爱网是一款专注于婚恋交友的应用，致力于帮助用户找到真爱。</p>
          <p>版本号：1.0.0</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/user'

const router = useRouter()
const userStore = useUserStore()
const showAboutModal = ref(false)

// 返回上一页
const goBack = () => {
  router.back()
}

// 更换手机号
const changePhone = () => {
  router.push('/login/sms')
}

// 显示关于弹窗
const showAbout = () => {
  showAboutModal.value = true
}

// 退出登录
const handleLogout = () => {
  userStore.logout()
  router.push('/login')
}
</script>

<style scoped>
.settings-page {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  max-width: 414px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: #f5f5f5;
  position: relative;
}

/* 导航栏样式 */
.nav-bar {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background-color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-button {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}

.title {
  flex: 1;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
}

/* 设置列表样式 */
.settings-list {
  margin-top: 10px;
  background-color: white;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
}

.settings-item:last-child {
  border-bottom: none;
}

.item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-icon {
  font-size: 20px;
}

.item-text {
  font-size: 16px;
  color: #333;
}

.item-arrow {
  color: #999;
  font-size: 20px;
}

.logout {
  color: #ff4444;
}

.logout .item-text {
  color: #ff4444;
}

/* 关于弹窗样式 */
.about-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: white;
  border-radius: 12px;
  width: 80%;
  max-width: 300px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
}

.close-btn {
  font-size: 24px;
  color: #999;
  cursor: pointer;
}

.modal-body {
  padding: 15px;
}

.modal-body p {
  margin: 10px 0;
  color: #666;
  line-height: 1.5;
}
</style> 